<?php
$str = "官网www.houdunwang.com 论坛http://bbs.houdunwang.com,我的网名叫做houdun";
//将  houdun 描红
//$preg = "/(houdun)/is";
//$newStr = preg_replace($preg,'<span style="color: red;">\1</span>',$str);

//将.com描成蓝色
$preg1 = "/(\.)(com)/is";
$newStr1 = preg_replace($preg1,'\1<span style="color:blue;">\2</span>',$str);
//echo $newStr1;

//匹配开始和结束
$p = preg_match('/^12/',1212);
//var_dump($p);